SELECT db ,type ,cnt FROM
( SELECT 'TABLE' type,table_schema db, count(*) cnt
FROM information_schema.tables a
WHERE table_type='BASE TABLE' AND table_schema='oa'
GROUP BY table_schema
UNION ALL
SELECT 'EVENTS' type,event_schema db,count(*) cnt
FROM information_schema.events b
WHERE event_schema='oa'
GROUP BY event_schema
UNION ALL
SELECT 'TRIGGERS' type,trigger_schema db,count(*) cnt
FROM information_schema.triggers c
WHERE trigger_schema='oa'
GROUP BY trigger_schema
UNION ALL
SELECT 'PROCEDURE' type,routine_schema db,count(*) cnt
FROM information_schema.ROUTINES d
WHERE ROUTINE_TYPE = 'PROCEDURE' AND routine_schema='oa'
GROUP By db
UNION ALL
SELECT 'FUNCTION' type,routine_schema db,count(*) cnt
FROM information_schema.ROUTINES d
WHERE ROUTINE_TYPE = 'FUNCTION' AND routine_schema='oa'
GROUP BY db
UNION ALL
SELECT 'VIEWS' type,table_schema db,count(*) cnt
FROM information_schema.VIEWS f
WHERE table_schema='oa'
GROUP BY table_schema ) t
ORDER BY db,type;